function [mu, vari] = initBGparam(frames)
% INITBGPARAM estimates the background model paramters mean MU and variance
%    VARI on image stack FRAMES.
% 
% Project:  Foreground detection [Bildfolgen LU]@CVL/TUWIEN
% Author:   Thomas Rittler (0125728)
% Date:     03/2011

mu = sum(frames, 4)/size(frames,4);
% sigma = std(frames, 1, 4); % OOM ERROR

vari = zeros(size(mu));
for i=1:size(frames,4)
    vari = vari + (frames(:,:,:,i)-mu).^2;
end
vari = vari/size(frames,4);
end